# @Author   : 懒羊羊
# @File     : loginpage.py
# @Time     : 2024/12/4 19:51
import os
import time

import pytest
from selenium.webdriver.chrome import webdriver
from selenium.webdriver.common.by import By

from common.config import data_path
from common.doFile import DoExcel

eFile = os.path.join(data_path, "ecshop.xlsx")
dl = DoExcel().readExcelRowCol(eFile, "login", 2, 2, 1, 2)


def login(wd, username, password):
    wd.get("http://192.168.88.102/user.php")
    wd.maximize_window()

    wd.find_element(By.CSS_SELECTOR, "input[name='username']").send_keys(username)

    wd.find_element(By.CSS_SELECTOR, "input[name='password']").send_keys(password)

    wd.find_element(By.CSS_SELECTOR, "input[name='submit']").click()

    time.sleep(2)


@pytest.mark.parametrize("username, password", dl)
def test_login1(username, password):
    wd = webdriver.WebDriver()
    login(wd, username, password)
